<!--保存按钮-->

<template>
  <div class="xy-save-button">
    <el-button :disabled="disabled" v-if="!value" @click="$emit('click')" size="small" :type="type"><slot></slot></el-button>
    <el-button :disabled="disabled" v-else :type="type" loading size="small">{{text}}</el-button>
  </div>
</template>

<script>
export default {
  props:{
    value:{
      type:Boolean,
      default:false
    },
    type:{
      type:String,
      default:"primary"
    },
    text:{
      type:String,
      default:"进行中..."
    }
  },
  data(){
    return {
      disabled:false
    }
  },
  mounted() {
    setInterval(()=>{
      if(this.$el.className.indexOf("is-disabled") != -1){
        this.disabled = true;
      }else{
        this.disabled = false;
      }
    },100);
  },
}
</script>


<style lang="scss" scoped>
  .xy-save-button{
    display: inline-block;
  }
</style>


